import http from '../../../common/httpUtil'
import * as types from './bankManagementMutationTypes'

const actions = {
  queryBank ({commit}, {pageIndex = 1, pageSize = 10} = {}) {
    commit(types.SYS_FILE_UPLOAD_QUERY_FILES_BEGIN)
    return http.getRaw(`admin/organ/bank/list?pageIndex=${pageIndex}&pageSize=${pageSize}`).then(data => {
      console.log(data)
      commit(types.SYS_FILE_UPLOAD_QUERY_FILES_SUC, {files: data.data.result})
      commit(types.SYS_FILE_UPLOAD_QUERY_FILES_COUNT_SUC, {totalCount: data.data.totalCount})
    })
  },
  searchBank ({commit}, {profileName, state, pageIndex = 1, pageSize = 10} = {}) {
    commit(types.SYS_FILE_UPLOAD_QUERY_FILES_BEGIN)
    return http.getRaw(`admin/organ/bank/list?pageIndex=${pageIndex}&pageSize=${pageSize}&profileName=${profileName}&state=${state}`)
      .then(data => {
        commit(types.SYS_FILE_UPLOAD_QUERY_FILES_SUC, {files: data.data.result})
        commit(types.SYS_FILE_UPLOAD_QUERY_FILES_COUNT_SUC, {totalCount: data.data.totalCount})
      })
  },
  editBank ({commit}, {formData}) {
    return http.get(`admin/organ/bank/check?organBankId=${formData.organBankId}&state=${formData.auditStatus}`).then(data => {
      console.log(data)
      commit(types.SYS_FILE_UPLOAD_UPDATE_SUC, {formData})
      return data
    })
  }
}

export default actions
